
    <script type="text/javascript">
    function postform(){
       var baseurl="{% url "game_list" %}?&r="+Math.random();
       option=getCookie('option');
       var url = baseurl+"&option="+option;
       delCookie('option');
       $.ajax({
                cache: false,
                type: "POST",
                url:url,
                data:$('#myformid').serialize(),// 你的formid
{#                async: false,#}
                dataType: "json",
                error: function(request) {
                    alert("Connection error");
                },
                success: function(data) {
                    alert(data.msg);
                    delCookie('pageper');

                    $("#mymodal").modal('hide');
                    var url="{% url "game_list" %}?&r="+Math.random();
                    window.location.href=url;
                 }
            });
    }



    function cat_game_conf(){
        var len = $("input:checkbox:checked").length;
        if (len>1){
            alert("一次只能编辑一个");
            return false;
        }
        else if  (len==0){
            alert("你还没有选中");
            return false;
        }
        var chk_value =[];
        $('input[name="check_box"]:checked').each(function(){
        chk_value.push($(this).val());
        });
        var server_id=chk_value[0];
        func="cat_game_conf";
        var url= "{% url "game_operation" %}?option="+func+"&r="+Math.random();
        postdata={serverid:server_id,csrfmiddlewaretoken:"{{csrf_token}}"};
        ajax_get(url,server_id,1,6,postdata,"查看游戏配置文件");
    }


 function change_opentime(func,action){
        $("#mymodal_opentime").modal('show')

 }

//ajax_get(url,sid,isresult,tdlocation,postdata)

function all_func(func,action) {
       var func=func;
       var len = $("input:checkbox:checked").length;
       if  (len == 0){
          alert("你还没有选中");
          return false;
       }
       var chk_value =[];
       $('input[name="check_box"]:checked').each(function(){
       chk_value.push($(this).val());
       });
       var confirmstring="确定要执行"+action+"?";
       var var1=confirm(confirmstring);
       if(var1 != true)
       {
           alert("exit!");
           return false;
       }
       //$('input').attr("value",""); //删除form表单的信息
       //$('input[name="csrfmiddlewaretoken"]').attr("value","{{csrf_token}}"); //
       var url= "{% url "game_operation" %}?option="+func+"&r="+Math.random();
       for (var i=0;i<chk_value.length;i++){
           sid=chk_value[i];
           postdata={serverid:sid,csrfmiddlewaretoken:"{{csrf_token}}"};
            ajax_get(url,sid,0,6,postdata,action);
       }
    }

$(document).ready(function() {
    $.ajaxSetup({
                layerIndex:-1,
                beforeSend: function () {
                    this.layerIndex = layer.load(0, { shade: [0.5, '#393D49'] });
                },
                complete: function () {
                    layer.close(this.layerIndex);
                },
                error: function () {
                    layer.alert('部分数据加载失败，可能会导致页面显示异常，请刷新后重试', {
                        skin: 'layui-layer-molv'
                       , closeBtn: 0
                       , shift: 4 //动画类型
                    });
                }
            });


    //window.onload=onload;
    $('input[name="game_id"]').change(function() {
        var game_id=$(this).val();
        var game_dbname='game_'+game_id;
        var log_dbname="log_"+game_id;
        var game_db_dbname='game_bg_'+game_id;
        $('input[name="game_dbname"]').attr("value",game_dbname);
        $('input[name="log_dbname"]').attr("value",log_dbname);
        $('input[name="game_db_dbname"]').attr("value",game_db_dbname);
        /* Act on the event */
    });


    $("#all").click(function(){
        if(this.checked){
            $("[name=check_box]:checkbox").prop("checked", true);
        }else{
            $("[name=check_box]:checkbox").removeAttr("checked");
        }
     });

    $('#mySelect').change(function(){
        var per=$(this).children('option:selected').val();
        delCookie('pageper');
        setCookie('pageper',per);
        var url="{% url url_name %}?&r="+Math.random();
        window.location.href=url;
        });


});
    </script>
